package nu.mine.tbje.easyEDT;

import javax.faces.application.Application;
import javax.faces.webapp.UIComponentTag;
import javax.faces.component.UIComponent;
import javax.faces.el.ValueBinding;
import javax.faces.context.FacesContext;
/***
 * Definie la balise edtMenu qui permet d'afficher l'emploi du temps d'un journée pour un 
 * enseignant ou un etudiant.
 * @author Tbje
 *
 */
public class EdtTodayTag extends UIComponentTag {
	public String cours = null;
	public String date = null;

	public String getComponentType() { return "nu.mine.tbje.easyEDT.EdtToday"; }
	public String getRendererType() { return null; }


	protected void setProperties(UIComponent component)
	{
		super.setProperties(component);

		if (cours != null) 
		{ 
			if (isValueReference(cours))
			{
				FacesContext context = FacesContext.getCurrentInstance();
				Application app = context.getApplication();
				ValueBinding vb = app.createValueBinding(cours);
				component.setValueBinding("cours", vb);                  
			}
			else 
				component.getAttributes().put("cours", cours);
		}                         
		if (date != null) 
		{ 
			if (isValueReference(date))
			{
				FacesContext context = FacesContext.getCurrentInstance();
				Application app = context.getApplication();
				ValueBinding vb = app.createValueBinding(date);
				component.setValueBinding("date", vb);                  
			}
			else 
				component.getAttributes().put("date", date);
		}   	}

	public void release()
	{
		super.release();
		cours = null;
	}


	public void setCours(String cours)
	{
		this.cours = cours;
	} 

	public void setDate(String date)
	{
		this.date = date;
	} 

}
